package _022_2_12

func changeDirect(direct *int) {
}

func dfsDetect(board [][]byte, row, cell, wordIndex int, word string, find *bool) {
	if wordIndex > len(word) {
		*find = true
		return
	}

	for i := row; i < len(board); i++ {
		for j := cell; j < len(board[0]); j++ {
			if board[i][j] == word[wordIndex] {
				dfsDetect(board, i, j+1, wordIndex+1, word, find)
			}
		}
	}

}

func exist(board [][]byte, word string) bool {
	find := false
	dfsDetect(board, 0, 0, 0, word, &find)

	return find

}
